﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataInfo;
using KenLib.BusinessManager;
public partial class JOINT_frmJ_IntroCompList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((JOINT_MstPage_JOINT)this.Master).changeTitle("派遣元企業一覧");
        ((JOINT_MstPage_JOINT)this.Master).HideLiArea("frmJ_IntroCompList");
        TextBox1.Focus();
        if (Session["役"] == null || Session["役"].ToString() == "")
        {
            Response.Redirect("~/frmD_Login.aspx");
        }
        if (Session["役"].ToString()=="1")
        {
            Response.Redirect("frmJ_IntroCompManager.aspx");
        }
        
        
        
        if (!IsPostBack)
        {
          //  grv.Visible = true;
       // AppCode_Common.ShowEmtyGrid<本社履歴>(grv, 5, "データがありません。", "");
            if (Session["JS00030F_List"] != null && Session["JS00030F_textbox"] != null)
            {
                grv.DataSource = (DataTable)Session["JS00030F_List"];
                grv.DataBind();
                TextBox1.Text = Session["JS00030F_textbox"].ToString();
            }
            else
            {
                Show();
            }
        }
     
    }
    protected void btn_派遣元企業情報_Click(object sender, EventArgs e)
    {
        Response.Redirect("frmJ_JointCompBasicInfoRef.aspx");
    }
    public void Show() //  tim kiem danh sach cac cong ty 
    {
        try
        {
            本社情報Manager frm = new 本社情報Manager();
            DataTable dt = new DataTable();
            string text = HttpUtility.HtmlEncode(TextBox1.Text.Trim().ToString());
            if (text != "")
            {
                //text = text.Replace("*", "");
                text = text.Replace("<", "&lt;");
                text = text.Replace(">", "&gt;");
                text = text.Replace("'", "&rsquo;");
            }
            dt = frm.Search_本社情報(text);
            if (dt.Rows.Count > 0)
            {
               
                grv.DataSource = dt;
                grv.DataBind();
                Session["JS00030F_List"] = dt;
                Session["JS00030F_textbox"] = TextBox1.Text;

            }
            else
            {
                grv.Visible = true;
                AppCode_Common.ShowEmtyGrid<本社情報>(grv, 5, "データがありません。", "");

            }
           
        }
        catch(Exception e) {
            throw e;
        
        }
    }
    protected void btn_検索_Click(object sender, EventArgs e)
    {
        Show();
    }
    protected void grv_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName.Equals("click"))
            {

                int ID = Int32.Parse((e.CommandArgument).ToString());
                string url = "frmJ_JointCompBasicInfoRef.aspx";
                url += "?ID=" + ID;
                Response.Redirect(url);
            }
     }
        catch { }
    }
    protected void grv_PageIndexChanging(object sender, GridViewPageEventArgs e)// phan trang.
    {
        grv.PageIndex = e.NewPageIndex;
        this.Show();
    }
}
